package cn.four.hqServer.modules.balance.controller;

import cn.four.hqServer.common.result.Result;
import cn.four.hqServer.modules.balance.service.LycCardInfoService;
import cn.four.hqServer.modules.balance.service.LycUserInfoService;
import cn.four.hqServer.modules.userlogin.vo.UserLoginVo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author znb
 * @since 2023-02-23
 */
@CrossOrigin
@RestController
@RequestMapping("/balance/hqCardInfo")
public class LycCardInfoController {
    @Resource
    private LycCardInfoService cardInfoService;

    @Resource
    private LycUserInfoService userInfoService;

    //为了提交

    @GetMapping("/getBalance")
    public Result getBalance(HttpServletRequest request) {
        //用session拿到用户信息
        UserLoginVo userInfo = (UserLoginVo) request.getSession().getAttribute("userInfo");
        if (userInfo != null)
            return cardInfoService.getBalance(userInfo.getUserId());
        else
            return Result.error("请登录");
    }
}
